linux系统中只删除所有文件或只删除所有目录 您所在的位置:网站首页 centos 删除文件夹下所有文件 linux系统中只删除所有文件或只删除所有目录

linux系统中只删除所有文件或只删除所有目录

2022-03-26 16:21| 来源: 网络整理| 查看: 265

linux系统中只删除所有文件或只删除所有目录 转载

mb5ff2f2ed7d163 2021-04-15 09:23:00 ©著作权

文章标签 centos 测试数据 IT 文章分类 IT业界 其它

linux系统中只删除所有文件或只删除所有目录https://blog.51cto.com/u_15075520/3377715

 

1、创建测试数据

[root@centos7 test2]# touch a.txt b.txt c.txt; mkdir test01 test02 test03 [root@centos7 test2]# ls a.txt b.txt c.txt test01 test02 test03

 

2、删除所有文件

[root@centos7 test2]# ls --file-type a.txt b.txt c.txt test01/ test02/ test03/ [root@centos7 test2]# ls --file-type | grep -v "/$" a.txt b.txt c.txt [root@centos7 test2]# ls --file-type | grep -v "/$" | xargs rm -f [root@centos7 test2]# ls test01 test02 test03

 

3、删除所有的目录文件

[root@centos7 test2]# touch a.txt b.txt c.txt [root@centos7 test2]# ls a.txt b.txt c.txt test01 test02 test03 [root@centos7 test2]# ls --file-type a.txt b.txt c.txt test01/ test02/ test03/ [root@centos7 test2]# ls --file-type | grep "/$" test01/ test02/ test03/ [root@centos7 test2]# ls --file-type | grep "/$" | xargs rm -rf [root@centos7 test2]# ls a.txt b.txt c.txt

 

收藏 评论 分享 微博 QQ 微信 举报

上一篇:linux系统中提取具有指定列的行

下一篇:FastAdmin用什么弹窗组件



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有